package com.yunban.project.template.controller;

import net.lab1024.sa.base.EventEnum;
import com.yunban.project.template.model.dto.DecoderReq;
import com.yunban.project.template.model.dto.DecoderSearchReq;
import com.yunban.project.template.model.vo.DecoderResp;
import com.yunban.project.template.service.DecoderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author: lijiajun
 * @date: 2024-11-07
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "模板-word抽取译码器模块")
@RequestMapping("/decoder-api")
public class DecoderController {

    @Resource
    private DecoderService decoderService;

    @GetMapping("/search")
    @Operation(summary = "查询word抽取译码器列表")
    PageResult<DecoderResp> getDecoderList(DecoderSearchReq req) {
        return this.decoderService.getDecoderList(req);
    }

    @PostMapping
    @Operation(summary = "添加word抽取译码器")
    Boolean saveDecoder(@RequestBody @Validated DecoderReq req) {
        return this.decoderService.saveDecoder(req);
    }

    @PutMapping("/{id}")
    @Operation(summary = "修改word抽取译码器")
    Boolean editDecoder(@PathVariable long id, @RequestBody @Validated DecoderReq req) {
        return this.decoderService.editDecoder(id, req);
    }

    @PostMapping("/{id}/{event}")
    @Operation(summary = "修改word抽取译码器启用状态")
    Boolean updateState(@PathVariable long id, @PathVariable EventEnum event) {
        return this.decoderService.updateState(id, event);
    }

}
